var myPage = new function () {
    'use strict';
    return {
        params:{
            page : 1,
            rows:null,
            total:null
        },
        init:function ($options) {
            this.params = $options;
        },
        nextPage:function () {
             var count = this.params.total - this.params.page*this.params.rows;
             if(count > 0){
                this.params.page += 1;
                return true;
             }else{
                 window.top.sendErrorMsg('至末页');
                 return false;
             }
        },
        beforePage:function () {
            if(this.params.page -1 > 0){
                this.params.page -= 1;
                return true;
            }else {
                window.top.sendErrorMsg('至顶页');
                return false;
            }
        },
        getParams:function () {
            return this.params;
        },
        setTotal:function ($total) {
          this.params.total = $total;
        },
        ajax:function (_url,_options,_callback) { //ajax
            var $this = this;
            $.ajax({
                url:baseUrl+_url,
                data:$this.params,
                type:'POST',
                dataType:'json',
                complete:function(XMLHttpRequest, textStatus){
                    if(textStatus != 'success'){
                        return false;
                    }
                    var result = XMLHttpRequest.responseJSON || XMLHttpRequest.responseText;
                    if(_callback) _callback.call(this, result);
                }

            })
        }
    }

};